package flc.ast.activity;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;

import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.SeekBar;

import com.blankj.utilcode.util.ColorUtils;
import com.blankj.utilcode.util.ImageUtils;
import com.blankj.utilcode.util.PermissionUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.stark.appwidget.lib.AppWidgetAdder;

import java.util.ArrayList;
import java.util.List;

import flc.ast.BaseAc;
import flc.ast.Constant;
import flc.ast.R;
import flc.ast.adapter.BgColorAdapter;
import flc.ast.adapter.ColorAdapter;
import flc.ast.bean.ComponentBean;
import flc.ast.bean.MyBgColorBean;
import flc.ast.bean.MyColorBean;
import flc.ast.databinding.ActivityEditTimeBinding;
import flc.ast.utils.AppSpUtils;
import flc.ast.view.MyWidgetLong;
import flc.ast.view.MyWidgetShort;
import flc.ast.widget.calendar.Calendar10Widget;
import flc.ast.widget.calendar.Calendar1Widget;
import flc.ast.widget.calendar.Calendar2Widget;
import flc.ast.widget.calendar.Calendar3Widget;
import flc.ast.widget.calendar.Calendar4Widget;
import flc.ast.widget.calendar.Calendar5Widget;
import flc.ast.widget.calendar.Calendar6Widget;
import flc.ast.widget.calendar.Calendar7Widget;
import flc.ast.widget.calendar.Calendar8Widget;
import flc.ast.widget.calendar.Calendar9Widget;
import flc.ast.widget.time.Time10Widget;
import flc.ast.widget.time.Time1Widget;
import flc.ast.widget.time.Time2Widget;
import flc.ast.widget.time.Time3Widget;
import flc.ast.widget.time.Time4Widget;
import flc.ast.widget.time.Time5Widget;
import flc.ast.widget.time.Time6Widget;
import flc.ast.widget.time.Time7Widget;
import flc.ast.widget.time.Time8Widget;
import flc.ast.widget.time.Time9Widget;
import flc.ast.widget.weather.Weather1Widget;
import flc.ast.widget.weather.Weather2Widget;
import flc.ast.widget.weather.Weather3Widget;
import flc.ast.widget.weather.Weather4Widget;
import flc.ast.widget.weather.Weather5Widget;
import flc.ast.widget.weather.Weather6Widget;
import io.reactivex.rxjava3.core.ObservableEmitter;
import stark.common.basic.constant.Extra;
import stark.common.basic.device.BatteryUtil;
import stark.common.basic.utils.BitmapUtil;
import stark.common.basic.utils.FastClickUtil;
import stark.common.basic.utils.FileUtil;
import stark.common.basic.utils.IntentUtil;
import stark.common.basic.utils.RxUtil;

public class EditTimeActivity extends BaseAc<ActivityEditTimeBinding> {

    private int mSelTime = 0;//要编辑的布局
    private ComponentBean mEditTimeBean;
    private BgColorAdapter bgColorAdapter;
    private int oldBgColorPos = 0;
    private ColorAdapter textColorAdapter;
    private int oldTextColorPos = 0;
    private Integer selBgColor;
    private String selTextColor;

    public static void start(Context context, int selIndex, ComponentBean componentBean) {
        Intent intent = IntentUtil.getIntent(context, EditTimeActivity.class);
        intent.putExtra(Extra.POS, selIndex);
        intent.putExtra(Extra.DATA, componentBean);
        context.startActivity(intent);
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_edit_time;
    }

    @Override
    protected void initView() {
        mDataBinding.ivEditTimeBack.setOnClickListener(v -> onBackPressed());

        mSelTime = getIntent().getIntExtra(Extra.POS, 0);
        mDataBinding.tvEditTimeAdd.setOnClickListener(this);
        //背景颜色
        mDataBinding.rvEditBgColorList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
        bgColorAdapter = new BgColorAdapter();
        mDataBinding.rvEditBgColorList.setAdapter(bgColorAdapter);
        bgColorAdapter.setOnItemClickListener(this);
        //字体颜色
        mDataBinding.rvEditTextColorList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
        textColorAdapter = new ColorAdapter();
        mDataBinding.rvEditTextColorList.setAdapter(textColorAdapter);
        textColorAdapter.setOnItemClickListener(this);

        //背景透明度
//        mDataBinding.sbBgAlpha.setMax(100);
//        mDataBinding.sbBgAlpha.setProgress(100);
//        mDataBinding.sbBgAlpha.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
//            @Override
//            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
//                int baseColor = Color.parseColor(bgColorAdapter.getItem(oldBgColorPos).getColor());
//                int alpha = (int) (255 * ((float) progress / 100)); // 50%透明度，255是完全不透明
//                int color = Color.argb(alpha, Color.red(baseColor), Color.green(baseColor), Color.blue(baseColor));
//                updateBgColor(ColorUtils.int2ArgbString(color));
//            }
//
//            @Override
//            public void onStartTrackingTouch(SeekBar seekBar) {
//            }
//
//            @Override
//            public void onStopTrackingTouch(SeekBar seekBar) {
//            }
//        });

        mDataBinding.sbTextAlpha.setMax(100);
        mDataBinding.sbTextAlpha.setProgress(100);
        mDataBinding.sbTextAlpha.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                int baseColor = Color.parseColor(textColorAdapter.getItem(oldTextColorPos).getColor());
                int alpha = (int) (255 * ((float) progress / 100)); // 50%透明度，255是完全不透明
                int color = Color.argb(alpha, Color.red(baseColor), Color.green(baseColor), Color.blue(baseColor));
                updateTextColor(ColorUtils.int2ArgbString(color));
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
            }
        });
    }

    @Override
    protected void onItemClickCallback(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        if (adapter == bgColorAdapter) {
            bgColorAdapter.getItem(oldBgColorPos).setSelect(false);
            bgColorAdapter.notifyItemChanged(oldBgColorPos);
            oldBgColorPos = position;
            bgColorAdapter.getItem(position).setSelect(true);
            bgColorAdapter.notifyItemChanged(position);
            selBgColor = bgColorAdapter.getItem(position).getRes();
            updateBgColor(selBgColor);
        } else if (adapter == textColorAdapter) {
            textColorAdapter.getItem(oldTextColorPos).setSelect(false);
            textColorAdapter.notifyItemChanged(oldTextColorPos);
            oldTextColorPos = position;
            textColorAdapter.getItem(position).setSelect(true);
            textColorAdapter.notifyItemChanged(position);
            selTextColor = textColorAdapter.getItem(position).getColor();
            updateTextColor(selTextColor);
        }
    }

    @Override
    protected void onClickCallback(View v) {
        switch (v.getId()) {
            case R.id.tvEditTimeAdd://添加到桌面
                addWidget();
                break;
            default:
                break;
        }
    }


    //添加小组件
    private void addWidget() {
        switch (mSelTime) {
            case 1:
                createWidget(R.layout.widget_time1, MyWidgetShort.class);
                break;
            case 2:
                createWidget(R.layout.widget_time2, MyWidgetLong.class);
                break;
            case 3:
                createWidget(R.layout.widget_time3, MyWidgetLong.class);
                break;
            case 4:
                createWidget(R.layout.widget_time4, MyWidgetShort.class);
                break;
            case 5:
                createWidget(R.layout.widget_time5, MyWidgetShort.class);
                break;
            case 6:
                createWidget(R.layout.widget_time6, MyWidgetLong.class);
                break;
            case 7:
                createWidget(R.layout.widget_time7, MyWidgetLong.class);
                break;
            case 8:
                createWidget(R.layout.widget_time8, MyWidgetShort.class);
                break;
            case 9:
                createWidget(R.layout.widget_time9, MyWidgetShort.class);
                break;
            case 10:
                createWidget(R.layout.widget_time10, MyWidgetShort.class);
                break;
            default:
                break;
        }
    }

    //创建小组件
    private void createWidget(int layout, Class<? extends AppWidgetProvider> cls) {
        //要想应用能够接收到开机广播自启动，需具备以下两个条件，1、申请到悬浮窗权限 2、请求忽略电池优化(荣耀pro20手机实际测试到可以不用申请悬浮窗权限也能收到开机广播)
        //1、申请悬浮窗权限(如果权限请求被用户拒绝，是否每次进来都要请求请开发人员自己做处理，这里只是demo，直接每次都请求了)
        getPermission(layout, cls);
        //2、请求忽略电池优化(如果请求被用户拒绝，是否每次进来都要请求请开发人员自己做处理，这里只是demo，直接每次都请求了)
        BatteryUtil.reqIgnoreBatteryOptimizations(mContext);
    }

    //获取权限
    private void getPermission(int layout, Class<? extends AppWidgetProvider> cls) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            PermissionUtils.requestDrawOverlays(new PermissionUtils.SimpleCallback() {
                @Override
                public void onGranted() {
                    showDialog(getString(R.string.create_ing));
                    RxUtil.create(new RxUtil.Callback<Boolean>() {
                        private String filePath;

                        @Override
                        public void doBackground(ObservableEmitter<Boolean> emitter) {
                            Bitmap bitmap = null;
                            switch (mSelTime) {
                                case 1:
                                    AppSpUtils.saveTime1Bg(selBgColor);
                                    AppSpUtils.saveTime1Color(selTextColor);
                                    bitmap = ImageUtils.view2Bitmap(mDataBinding.includeEditTime1.rlTime1View);
                                    break;
                                case 2:
                                    AppSpUtils.saveTime2Bg(selBgColor);
                                    AppSpUtils.saveTime2Color(selTextColor);
                                    bitmap = ImageUtils.view2Bitmap(mDataBinding.includeEditTime2.rlTime2View);
                                    break;
                                case 3:
                                    AppSpUtils.saveTime3Bg(selBgColor);
                                    AppSpUtils.saveTime3Color(selTextColor);
                                    bitmap = ImageUtils.view2Bitmap(mDataBinding.includeEditTime3.rlTime3View);
                                    break;
                                case 4:
                                    AppSpUtils.saveTime4Bg(selBgColor);
                                    AppSpUtils.saveTime4Color(selTextColor);
                                    bitmap = ImageUtils.view2Bitmap(mDataBinding.includeEditTime4.rlTime4View);
                                    break;
                                case 5:
                                    AppSpUtils.saveTime5Bg(selBgColor);
                                    AppSpUtils.saveTime5Color(selTextColor);
                                    bitmap = ImageUtils.view2Bitmap(mDataBinding.includeEditTime5.rlTime5View);
                                    break;
                                case 6:
                                    AppSpUtils.saveTime6Bg(selBgColor);
                                    AppSpUtils.saveTime6Color(selTextColor);
                                    bitmap = ImageUtils.view2Bitmap(mDataBinding.includeEditTime6.rlTime6View);
                                    break;
                                case 7:
                                    AppSpUtils.saveTime7Bg(selBgColor);
                                    AppSpUtils.saveTime7Color(selTextColor);
                                    bitmap = ImageUtils.view2Bitmap(mDataBinding.includeEditTime7.rlTime7View);
                                    break;
                                case 8:
                                    AppSpUtils.saveTime8Bg(selBgColor);
                                    AppSpUtils.saveTime8Color(selTextColor);
                                    bitmap = ImageUtils.view2Bitmap(mDataBinding.includeEditTime8.rlTime8View);
                                    break;
                                case 9:
                                    AppSpUtils.saveTime8Bg(selBgColor);
                                    AppSpUtils.saveTime8Color(selTextColor);
                                    bitmap = ImageUtils.view2Bitmap(mDataBinding.includeEditTime9.rlTime9View);
                                    break;
                                case 10:
                                    AppSpUtils.saveTime8Bg(selBgColor);
                                    AppSpUtils.saveTime8Color(selTextColor);
                                    bitmap = ImageUtils.view2Bitmap(mDataBinding.includeEditTime10.rlTime10View);
                                    break;
                                default:
                                    break;
                            }
//                            ImageUtils.save2Album(bitmap, Bitmap.CompressFormat.PNG);
                            emitter.onNext(true);
                        }

                        @Override
                        public void accept(Boolean obj) {
                            dismissDialog();
                            AppWidgetAdder.getInstance().addAppWidget(layout, cls);
                        }
                    });
                }

                @Override
                public void onDenied() {
                    ToastUtils.showShort(R.string.permission_no_tips);
                }
            });
        }
    }


    //修改字体颜色
    private void updateTextColor(String color) {
        switch (mSelTime) {
            case 1:
                mDataBinding.includeEditTime1.tvTime1Date.setTextColor(Color.parseColor(color));
                mDataBinding.includeEditTime1.tvTime1Time.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, "09:28:24", Color.parseColor(color), 22, "font/ziti4.otf"));
                break;
            case 2:
                mDataBinding.includeEditTime2.tvTime2TimeH.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, "09", Color.parseColor(color), 32, "font/ziti4.otf"));
                mDataBinding.includeEditTime2.tvTime2TimeM.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, "45", Color.parseColor(color), 32, "font/ziti4.otf"));
                mDataBinding.includeEditTime2.tvTime2TimeS.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, "52", Color.parseColor(color), 32, "font/ziti4.otf"));
                mDataBinding.includeEditTime2.tvTime2Dot1.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, ":", Color.parseColor(color), 32, "font/ziti4.otf"));
                mDataBinding.includeEditTime2.tvTime2Dot2.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, ":", Color.parseColor(color), 32, "font/ziti4.otf"));
                mDataBinding.includeEditTime2.tvTime2Hour.setTextColor(Color.parseColor(color));
                mDataBinding.includeEditTime2.tvTime2Min.setTextColor(Color.parseColor(color));
                mDataBinding.includeEditTime2.tvTime2Sec.setTextColor(Color.parseColor(color));
                break;
            case 3:
                mDataBinding.includeEditTime3.tvTime3Time.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, "09:28", Color.parseColor(color), 40, "font/ziti5.ttf"));
                mDataBinding.includeEditTime3.tvTime3Date.setTextColor(Color.parseColor(color));
                break;
            case 4:
                mDataBinding.includeEditTime4.tvTime4Time.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, "09:12", Color.parseColor(color), 20, "font/ziti5.ttf"));
                break;
            case 5:
                mDataBinding.includeEditTime5.tvTime5Time.setTextColor(Color.parseColor(color));
                mDataBinding.includeEditTime5.tvTime5Date.setTextColor(Color.parseColor(color));
                break;
            case 6:
                mDataBinding.includeEditTime6.tvTime6TimeH.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, "09", Color.parseColor(color), 26, "font/ziti3.ttf"));
                mDataBinding.includeEditTime6.tvTime6TimeM.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, "34", Color.parseColor(color), 26, "font/ziti3.ttf"));
                mDataBinding.includeEditTime6.tvTime6Dot.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, ":", Color.parseColor(color), 26, "font/ziti3.ttf"));
                mDataBinding.includeEditTime6.tvTime6Week.setTextColor(Color.parseColor(color));
                break;
            case 7:
                mDataBinding.includeEditTime7.tvTime7TimeH.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, "09", Color.parseColor(color), 28, "font/ziti4.otf"));
                mDataBinding.includeEditTime7.tvTime7TimeM.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, "45", Color.parseColor(color), 28, "font/ziti4.otf"));
                mDataBinding.includeEditTime7.tvTime7TimeS.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, "52", Color.parseColor(color), 28, "font/ziti4.otf"));
                mDataBinding.includeEditTime7.tvTime7Dot1.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, ":", Color.parseColor(color), 28, "font/ziti4.otf"));
                mDataBinding.includeEditTime7.tvTime7Dot2.setImageBitmap(BitmapUtil.text2BmpWithAssetFont(this, ":", Color.parseColor(color), 28, "font/ziti4.otf"));
                break;
            case 8:
                mDataBinding.includeEditTime8.tvTime8Time.setTextColor(Color.parseColor(color));
                mDataBinding.includeEditTime8.tvTime8Week.setTextColor(Color.parseColor(color));
                break;
            case 9:
                mDataBinding.includeEditTime9.tvTime9Time.setTextColor(Color.parseColor(color));
                mDataBinding.includeEditTime9.tvTime9Week.setTextColor(Color.parseColor(color));
                break;
            case 10:
                mDataBinding.includeEditTime10.tvTime10Time.setTextColor(Color.parseColor(color));
                mDataBinding.includeEditTime10.tvTime10Week.setTextColor(Color.parseColor(color));
                break;
            default:
                break;
        }
    }


    //修改背景颜色
    //修改背景颜色
    private void updateBgColor(Integer res) {
        switch (mSelTime) {
            case 1:
                mDataBinding.includeEditTime1.llTime1Bg.setBackgroundResource(res);
                break;
            case 2:
                mDataBinding.includeEditTime2.llTime2Bg.setBackgroundResource(res);
                break;
            case 3:
                mDataBinding.includeEditTime3.llTime3Bg.setBackgroundResource(res);
                break;
            case 4:
                mDataBinding.includeEditTime4.llTime4Bg.setBackgroundResource(res);
                break;
            case 5:
                mDataBinding.includeEditTime5.llTime5Bg.setBackgroundResource(res);
                break;
            case 6:
                mDataBinding.includeEditTime6.llTime6Bg.setBackgroundResource(res);
                break;
            case 7:
                mDataBinding.includeEditTime7.llTime7Bg.setBackgroundResource(res);
                break;
            case 8:
                mDataBinding.includeEditTime8.llTime8Bg.setBackgroundResource(res);
                break;
            case 9:
                mDataBinding.includeEditTime9.llTime9Bg.setBackgroundResource(res);
                break;
            case 10:
                mDataBinding.includeEditTime10.llTime10Bg.setBackgroundResource(res);
                break;
            default:
                break;
        }
    }

    @Override
    protected void initData() {
        //背景颜色
        List<MyBgColorBean> listBg = new ArrayList<>();
        listBg.add(new MyBgColorBean(R.drawable.time_1, "", false));
        listBg.add(new MyBgColorBean(R.drawable.time_2, "", false));
        listBg.add(new MyBgColorBean(R.drawable.time_3, "", false));
        listBg.add(new MyBgColorBean(R.drawable.time_4, "", false));
        listBg.add(new MyBgColorBean(R.drawable.time_5, "", false));
        bgColorAdapter.setList(listBg);
        //字体颜色
        List<MyColorBean> listText = new ArrayList<>();
        listText.add(new MyColorBean("#FFFFFF", false));
        listText.add(new MyColorBean("#181818", false));
        listText.add(new MyColorBean("#5BC6E7", false));
        listText.add(new MyColorBean("#FCFDBA", false));
        listText.add(new MyColorBean("#ABE8FF", false));
        listText.add(new MyColorBean("#FFC5DC", false));
        listText.add(new MyColorBean("#97CAFF", false));
        listText.add(new MyColorBean("#0099FA", false));
        listText.add(new MyColorBean("#00BAC0", false));
        listText.add(new MyColorBean("#56EDF4", false));
        listText.add(new MyColorBean("#FFD201", false));
        listText.add(new MyColorBean("#817FFF", false));
        listText.add(new MyColorBean("#838EC6", false));
        listText.add(new MyColorBean("#FFBEB9", false));
        textColorAdapter.setList(listText);
        //准备布局
        setLayout();
    }

    //展示对应布局
    private void setLayout() {
        switch (mSelTime) {
            case 1:
                selTextColor = "#FFFFFF";
                selBgColor = R.drawable.time_1;

                mDataBinding.includeEditTime1.tvTime1Date.setTextColor(Color.parseColor(selTextColor));
                mDataBinding.includeEditTime1.tvTime1Time.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, "09:28:24",
                                Color.parseColor(selTextColor), 22,
                                "font/ziti4.otf"));

                mDataBinding.includeEditTime1.llTime1Bg.setBackgroundResource(selBgColor);
                mDataBinding.includeEditTime1.rlTime1View.setVisibility(View.VISIBLE);
                break;
            case 2:
                selTextColor = "#FFFFFF";
                selBgColor = R.drawable.time_2_default;

                mDataBinding.includeEditTime2.tvTime2TimeH.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, "09",
                                Color.parseColor(selTextColor), 32, "font/ziti4.otf"));
                mDataBinding.includeEditTime2.tvTime2TimeM.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, "45",
                                Color.parseColor(selTextColor), 32, "font/ziti4.otf"));
                mDataBinding.includeEditTime2.tvTime2TimeS.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, "52",
                                Color.parseColor(selTextColor), 32, "font/ziti4.otf"));
                mDataBinding.includeEditTime2.tvTime2Dot1.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, ":",
                                Color.parseColor(selTextColor), 32, "font/ziti4.otf"));
                mDataBinding.includeEditTime2.tvTime2Dot2.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, ":",
                                Color.parseColor(selTextColor), 32, "font/ziti4.otf"));
                mDataBinding.includeEditTime2.tvTime2Hour.setTextColor(Color.parseColor(selTextColor));
                mDataBinding.includeEditTime2.tvTime2Min.setTextColor(Color.parseColor(selTextColor));
                mDataBinding.includeEditTime2.tvTime2Sec.setTextColor(Color.parseColor(selTextColor));

                mDataBinding.includeEditTime2.llTime2Bg.setBackgroundResource(selBgColor);

                mDataBinding.includeEditTime2.rlTime2View.setVisibility(View.VISIBLE);
                break;
            case 3:
                selTextColor = "#6F500A";
                selBgColor = R.drawable.time_3_default;

                mDataBinding.includeEditTime3.tvTime3Time.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, "09:28",
                                Color.parseColor(selTextColor), 40, "font/ziti5.ttf"));
                mDataBinding.includeEditTime3.tvTime3Date.setTextColor(Color.parseColor(selTextColor));

                mDataBinding.includeEditTime3.llTime3Bg.setBackgroundResource(selBgColor);

                mDataBinding.includeEditTime3.rlTime3View.setVisibility(View.VISIBLE);
                break;
            case 4:
                selTextColor = "#FFFFFF";
                selBgColor = R.drawable.time_4_default;

                mDataBinding.includeEditTime4.tvTime4Time.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, "09:12",
                                Color.parseColor(selTextColor), 20, "font/ziti5.ttf"));

                mDataBinding.includeEditTime4.llTime4Bg.setBackgroundResource(selBgColor);

                mDataBinding.includeEditTime4.rlTime4View.setVisibility(View.VISIBLE);
                break;
            case 5:
                selTextColor = "#FFFFFF";
                selBgColor = R.drawable.time_5_default;

                mDataBinding.includeEditTime5.tvTime5Time.setTextColor(Color.parseColor(selTextColor));
                mDataBinding.includeEditTime5.tvTime5Date.setTextColor(Color.parseColor(selTextColor));

                mDataBinding.includeEditTime5.llTime5Bg.setBackgroundResource(selBgColor);

                mDataBinding.includeEditTime5.rlTime5View.setVisibility(View.VISIBLE);
                break;
            case 6:
                selTextColor = "#333333";
                selBgColor = R.drawable.frame_1;

                mDataBinding.includeEditTime6.tvTime6TimeH.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, "09",
                                Color.parseColor(selTextColor), 26, "font/ziti3.ttf"));
                mDataBinding.includeEditTime6.tvTime6TimeM.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, "34",
                                Color.parseColor(selTextColor), 26, "font/ziti3.ttf"));
                mDataBinding.includeEditTime6.tvTime6Dot.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, ":",
                                Color.parseColor(selTextColor), 26, "font/ziti3.ttf"));
                mDataBinding.includeEditTime6.tvTime6Week.setTextColor(Color.parseColor(selTextColor));

                mDataBinding.includeEditTime6.llTime6Bg.setBackgroundResource(selBgColor);

                mDataBinding.includeEditTime6.rlTime6View.setVisibility(View.VISIBLE);
                break;
            case 7:
                selTextColor = "#000000";
                selBgColor = R.drawable.frame_1;

                mDataBinding.includeEditTime7.tvTime7TimeH.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, "09",
                                Color.parseColor(selTextColor), 28, "font/ziti4.otf"));
                mDataBinding.includeEditTime7.tvTime7TimeM.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, "45",
                                Color.parseColor(selTextColor), 28, "font/ziti4.otf"));
                mDataBinding.includeEditTime7.tvTime7TimeS.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, "52",
                                Color.parseColor(selTextColor), 28, "font/ziti4.otf"));
                mDataBinding.includeEditTime7.tvTime7Dot1.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, ":",
                                Color.parseColor(selTextColor), 28, "font/ziti4.otf"));
                mDataBinding.includeEditTime7.tvTime7Dot2.setImageBitmap(
                        BitmapUtil.text2BmpWithAssetFont(mContext, ":",
                                Color.parseColor(selTextColor), 28, "font/ziti4.otf"));

                mDataBinding.includeEditTime7.llTime7Bg.setBackgroundResource(selBgColor);

                mDataBinding.includeEditTime7.rlTime7View.setVisibility(View.VISIBLE);
                break;
            case 8:
                selTextColor = "#000000";
                selBgColor = R.drawable.frame_2;

                mDataBinding.includeEditTime8.tvTime8Time.setTextColor(Color.parseColor(selTextColor));
                mDataBinding.includeEditTime8.tvTime8Week.setTextColor(Color.parseColor(selTextColor));

                mDataBinding.includeEditTime8.llTime8Bg.setBackgroundResource(selBgColor);

                mDataBinding.includeEditTime8.rlTime8View.setVisibility(View.VISIBLE);
                break;
            case 9:
                selTextColor = "#000000";
                selBgColor = R.drawable.frame_2;

                mDataBinding.includeEditTime9.tvTime9Time.setTextColor(Color.parseColor(selTextColor));
                mDataBinding.includeEditTime9.tvTime9Week.setTextColor(Color.parseColor(selTextColor));

                mDataBinding.includeEditTime9.llTime9Bg.setBackgroundResource(selBgColor);

                mDataBinding.includeEditTime9.rlTime9View.setVisibility(View.VISIBLE);
                break;
            case 10:
                selTextColor = "#000000";
                selBgColor = R.drawable.frame_2;

                mDataBinding.includeEditTime10.tvTime10Time.setTextColor(Color.parseColor(selTextColor));
                mDataBinding.includeEditTime10.tvTime10Week.setTextColor(Color.parseColor(selTextColor));

                mDataBinding.includeEditTime10.llTime10Bg.setBackgroundResource(selBgColor);

                mDataBinding.includeEditTime10.rlTime10View.setVisibility(View.VISIBLE);
                break;
            default:
                break;
        }
    }

}